package com.lw.lwte.common.helper;

import java.util.Collection;
import java.util.Map;
import java.util.Objects;

/**
 * 集合帮助类
 */
public class CollectionHelper {
    private CollectionHelper() {
    }

    /**
     * 集合是否为空
     *
     * @param collection 集合
     */
    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }

    /**
     * 集合是否不为空
     *
     * @param collection 集合
     */
    public static boolean isNotEmpty(Collection<?> collection) {
        return !isEmpty(collection);
    }

    /**
     * map是否为空
     *
     * @param map map
     */
    public static boolean isEmpty(Map map) {
        return map == null || map.isEmpty();
    }

    /**
     * map是否不为空
     *
     * @param map map
     */
    public static boolean isNotEmpty(Map map) {
        return !isEmpty(map);
    }

    /**
     * 数组是否空
     *
     * @param array 数组
     */
    public static boolean isEmpty(Object[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    /**
     * 数组不为空
     *
     * @param array 数组
     */
    public static boolean isNotEmpty(Object[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(int[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(int[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(long[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(long[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(float[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(float[] array) {
        return !isEmpty(array);
    }

    public static boolean isEmpty(double[] array) {
        return Objects.isNull(array) || array.length == 0;
    }

    public static boolean isNotEmpty(double[] array) {
        return !isEmpty(array);
    }
}
